import 'dart:math';
import 'dart:ui';

import 'package:flutter/material.dart';

class TestPainter extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    List<Offset> points = const [
      Offset(100, 100),
      Offset(100, 150),
      Offset(150, 150),
      Offset(200, 100),
    ];
    Paint paint = Paint();
    paint.strokeWidth = 10;
    paint.strokeCap = StrokeCap.round;
    paint.color = Colors.redAccent;
    canvas.drawPoints(PointMode.polygon, points, paint);

    canvas.drawCircle(Offset(100, 250), 50, paint);
    paint.style = PaintingStyle.stroke;
    canvas.drawCircle(Offset(250, 250), 50, paint);

    paint.strokeWidth = 2;
    Rect rect =
        Rect.fromCenter(center: Offset(100, 350), width: 100, height: 80);
    canvas.drawRect(rect, paint);
    paint.style = PaintingStyle.fill;
    RRect rrect = RRect.fromRectXY(rect.translate(150, 0), 8, 8);
    canvas.drawRRect(rrect, paint);

    Rect overRect =
        Rect.fromCenter(center: Offset(100, 450), width: 100, height: 80);
    canvas.drawOval(overRect, paint);
    canvas.drawArc(overRect.translate(150, 0), 0, pi * 1.3, true, paint);
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) => true;
}
